<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>expressões regulares</title>
        <script>
            function valida(){
                regex = RegExp(document.formulario.regex.value);
                //regex = /^\w{2,}[_.]?\w+@\w+([.][\w]+)+$/;
                valor = document.formulario.valor.value;
                OK = regex.exec(valor);
                if (OK){
                    alert("Valor valido");
                }else{
                    alert("Valor invalido");
                }
            }
        </script>
    </head>
    <body>
        <h1>Validando expressões regulares</h1>
        <form name="formulario">
            Regex:<input type="text" size="50" name="regex"/><br/>
            Valor:<input type="text" size="50" name="valor"/><br/>
            <input type="button" value="validar" onclick="valida();"/>
        </form>
    </body>
</html>
